import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vuejsx from "@vitejs/plugin-vue-jsx";
import { viteMockServe } from "vite-plugin-mock";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  alias: {
    "@": path.resolve(__dirname, "src"),
    comp: path.resolve(__dirname, "src/components"),
    public: path.resolve(__dirname, "public"),
    layouts: path.resolve(__dirname, "./src/layouts"),
    views: path.resolve(__dirname, "./src/views"),
    styles: path.resolve(__dirname, "./src/styles"),
    src: path.resolve(__dirname, "./src"),
    utils:path.resolve(__dirname,"./src/utils")
  },
  plugins: [
    vue(),
    vuejsx(),
    viteMockServe({
      supportTs: false,
    }),
  ],
  server:{
    proxy:{
      '/nodeapi': {
        target: 'http://127.0.0.1:4000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/nodeapi/, ''),
        // secure: false,  // 如果是https接口，需要配置这个参数,不是的话不用配置
      },
    }
  }
});
